'use strict';

const BaseController = require("./base");

class GameController extends BaseController {
    async findAllUser() {
        let allUser = await this.ctx.service.user.findUser();
        this.success(allUser);
    }

    async addGame() {
        let { appId } = this.ctx.request.query;
        let oneGame = await this.ctx.service.game.findOneGame(appId);
        if (oneGame) {
            this.faile("游戏已存在", -1000);
        } else {
            let res = await this.ctx.service.game.addGame({
                appId
            });
            if (res) {
                this.success(res);
            } else {
                this.faile(res, -1001);
            }
        }
    }

}

module.exports = GameController;
